Repository navigation
refactor: Untangle Context contracts and shared API helpers - #1237
sidneyswift wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
2 issues found across 29 files
Confidence score: 4/5
processContextOperation.tsandcontextOperationSchema.tsare both well over the under-100-line guideline, which makes these areas harder to maintain. Split the dispatch logic and schema action groups into cohesive modules.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/context/processContextOperation.ts">
<violation number="1" location="lib/context/processContextOperation.ts:15">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**
`processContextOperation.ts` remains 407 lines, well above the rule’s under-100-line limit; split the remaining action dispatch into cohesive modules.</violation>
</file>
<file name="lib/context/contextOperationSchema.ts">
<violation number="1" location="lib/context/contextOperationSchema.ts:17">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**
`contextOperationSchema.ts` is 180 lines, exceeding the guideline's under-100-line limit. Extract action groups into separate schema modules and compose them here.</violation>
</file>
Architecture diagram
sequenceDiagram
participant CC as Contract Consumer
participant BOC as buildContextOperationCatalog
participant COS as contextOperationSchema
participant PCO as processContextOperation
participant PO as Process Operations
participant AO as authorizeContextOwner
participant RPC as RPC/Dispatch
Note over CC,BOC: Contract-only consumers (no execution deps)
CC->>BOC: get request schemas
BOC->>COS: import schema
COS-->>BOC: validation schema
BOC-->>CC: request catalog
Note over PCO,PO: Execution path (isolated from contracts)
PCO->>COS: import schema
PCO->>PO: dispatch operations
PO->>AO: authorize owner
AO-->>PO: context
PO->>RPC: rpc/dispatch calls
Note over PCO,RPC: NEW: Boundary enforced - contracts no longer load execution services
alt HTTP API path
CC->>PCO: POST /api/context
PCO->>PO: process operation
else MCP tool path
CC->>PCO: handleContextToolOperation
PCO->>PO: process operation
end
alt Abort handling (unified)
PCO->>PCO: isAbortError (lib/errors)
Note over PCO: Shared error policy across workflows
end
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| normalizeCatalogPlanningModule, | ||
| } from "./normalizeCatalogPlanningModule"; | ||
| import { normalizeCatalogPlanningModule } from "./normalizeCatalogPlanningModule"; | ||
| import { contextOperationSchema } from "./contextOperationSchema"; |
There was a problem hiding this comment.
P2: Custom agent: Enforce Clear Code Style and Maintainability Practices
processContextOperation.ts remains 407 lines, well above the rule’s under-100-line limit; split the remaining action dispatch into cohesive modules.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/context/processContextOperation.ts, line 15:
<comment>`processContextOperation.ts` remains 407 lines, well above the rule’s under-100-line limit; split the remaining action dispatch into cohesive modules.</comment>
<file context>
@@ -1,198 +1,19 @@
- normalizeCatalogPlanningModule,
-} from "./normalizeCatalogPlanningModule";
+import { normalizeCatalogPlanningModule } from "./normalizeCatalogPlanningModule";
+import { contextOperationSchema } from "./contextOperationSchema";
-const briefFields = {
</file context>
| @@ -0,0 +1,180 @@ | |||
| import { z } from "zod"; | |||
There was a problem hiding this comment.
P2: Custom agent: Enforce Clear Code Style and Maintainability Practices
contextOperationSchema.ts is 180 lines, exceeding the guideline's under-100-line limit. Extract action groups into separate schema modules and compose them here.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/context/contextOperationSchema.ts, line 17:
<comment>`contextOperationSchema.ts` is 180 lines, exceeding the guideline's under-100-line limit. Extract action groups into separate schema modules and compose them here.</comment>
<file context>
@@ -0,0 +1,180 @@
+ max_characters: z.number().int().min(1000).max(32000).default(12000),
+};
+
+export const contextOperationSchema = z.discriminatedUnion("action", [
+ ...catalogCaseOperationSchemas,
+ ...evidenceAttachmentOperationSchemas,
</file context>
Summary
Separate Context schemas from execution; unify chat-title and AbortError policy; retire duplicate billing validator and superseded unused image adapter. Public request schema bytes and wire behavior are unchanged.
Verification
2,334 tests pass before obsolete adapter retirement; 239 active Sites/Higgsfield tests pass afterward. Repository lint and response-contract typecheck pass. Full TypeScript check retains exactly the same 214 baseline diagnostics, with zero additions. Independent review completed.
Scope and review
Part of the user-requested Recoup monorepo untangle-codebase workflow. Audit and decision log preceded implementation. Changes stay in this owning repository; no production deployment or main-branch merge requested. No broad comment/test-pruning sweep. Existing local work and retired checkouts preserved.
Each repository PR is independently reviewable; the Mono report will collect the coordinated audit, retained cases and check limitations.
Summary by cubic
Separates Context request schemas from execution logic and consolidates shared API helpers without changing any public request schema or wire behavior.
contextOperationSchemainto its own module so contract consumers no longer load authenticated execution services; a new boundary test enforces this.isAbortErrorintolib/errors/and relocatesgenerateChatTitletolib/chats/.Written for commit beacfbd. Summary will update on new commits.